<?php  
include "konek.php"; 
$username=$_POST['userid']; 
$password=$_POST['pass'];
$query=mysql_query("select * from guru where email='$username' and pass='$password'"); 
$cek=mysql_num_rows($query); 
$user=mysql_fetch_assoc($query);
$directory=$user['username'];
$remember=$_POST['remember'];
if($cek)
{	

if($remember>0)
{
	$hour = time() + 3600;
	setcookie('eletra', $username, $hour);
}
session_start();
$_SESSION['username'] = $username;
$_SESSION['status'] = 'Guru';
$_SESSION["RF"]["subfolder"] ="source/guru/$directory/";
echo '<script language="javascript">alert("Selamat Datang !");document.location="../pages/dashboard.php"</script>';
}
else
{
$query2=mysql_query("select * from siswa where email_sis='$username' and pass_sis='$password'");
$cek2=mysql_num_rows($query2);
$user2=mysql_fetch_assoc($query2);
$directory2=$user2['username'];
	if($cek2)
	{
	if($remember>0)
	{
		$hour = time() + 3600;
		setcookie('eletra', $username, $hour);
	}
	session_start();
	$_SESSION['username'] = $username;
	$_SESSION['status'] = 'siswa';
	
	$_SESSION["RF"]["subfolder"] ="source/siswa/$directory2/";
	echo '<script language="javascript">alert("Selamat Datang !");document.location="../pages/dashboard.php"</script>';
	}
	else
	{
		?>
	<script language="javascript">alert('username / password salah');
	document.location='../index.php'</script><?php	
	}
}

?> 